package com.yh.threadTest.pojo;

/**
 * @ClassName TestDaemon
 * @Description 测试守护线程
 * @Author 0715-YuHao
 * @Date 2020/11/14 13:43
 */
public class TestDaemon {

    public static void main(String[] args) {
        Runnable god = new God();
        Runnable man = new Man();
        Thread t1 = new Thread(god);
        t1.setDaemon(true);
        t1.start();
        new Thread(man).start();
    }

}

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("上帝保佑着你");
        }
    }
}

class Man implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("我活了" + i + "天");
        }
        System.out.println("GoodBye, World");
    }
}